﻿Imports AugmentLib.Database
Imports System.Configuration.ConfigurationManager
Imports AugmentLib.InputOutput.Encryption
Imports AugmentLib.WebComponent

Partial Class propertynotsalerentview
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("StaffId") Is Nothing Then
            Response.Redirect("Default.aspx")
        Else
            lblhidStaffId.Text = Session("StaffId").ToString
            lblhidStaffType.Text = Session("StaffType").ToString
        End If

        If Not Page.IsPostBack Then

            'Dim ListType As String
            If Not Request.QueryString("oid") Is Nothing Then
                lblhidPropertyId.Text = SymmetricDecryptFromHex(Request.QueryString("oid"), "augment")
                lblhidListType.Text = Me.Session("tp").ToString
                'Me.Session.Remove("tp")
                LoadProperty(lblhidPropertyId.Text, lblhidListType.Text)
                LoadPropertyPhoto(lblhidPropertyId.Text)
            Else
                Response.Redirect("Default.aspx")

            End If
        End If
    End Sub

    Private Sub LoadProperty(ByVal PropertyId As String, ByVal ListType As String)

        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable

        objDB.OpenConnection()

        objDB.dbVariable.SQLString = "SELECT a.PropertyId, r.Road, p.Project, t.[Type] as PropertyType, a.UnitNumber, " & _
                                "a.UnitNumber + ', ' + r.Road + ', ' + l.Location + ', ' + s.State + ', ' + c.Country as 'Address', " & _
                                "a.ListType, a.SRAmt, a.SRPSF, a.SRAskAmt, a.SRAskPSF, a.SRCreateDate, a.SRYes, " & _
                                "a.SCAmt, a.SCPSF, a.SCAskAmt, a.SCAskPSF, a.SCCreateDate, a.SCYes, a.SLAmt, a.SLPSF, " & _
                                "a.SLAskAmt, a.SLAskPSF, a.SLCreateDate, a.SLYes, a.SIAmt, a.SIPSF, a.SIAskAmt, a.SIAskPSF, a.SICreateDate, " & _
                                "a.SIYes, a.RRAmt, a.RRPSF, a.RRAskAmt, a.RRAskPSF, a.RRCreateDate, " & _
                                "a.RRYes, a.RCAmt, a.RCPSF, a.RCAskAmt, a.RCAskPSF, a.RCCreateDate, a.RCYes, " & _
                                "a.RLAmt, a.RLPSF, a.RLAskAmt, a.RLAskPSF, a.RLCreateDate, a.RLYes, a.RIAmt, a.RIPSF, " & _
                                "a.RIAskAmt, a.RIAskPSF, a.RICreateDate, a.RIYes, rs.[Name] as SLister, rs.Initial as SListerInitial, a.SListerId, a.RListerId, " & _
                                "rr.[Name] as RLister, rr.Initial as RListerInitial, a.KeyInOffice, a.ProjectRemark, a.PropertyDesc, " & _
                                "a.SignboardStatus, a.SignboardWhere, a.SignboardWhen, a.SurveySheet, " & _
                                "a.QuitRent, a.AssessmentBill, a.PendingStatus, a.PendingWho, " & _
                                "a.PendingWhen, a.PendingWhy, a.Tenure, a.ListHoldExpired, " & _
                                "a.Access, a.Condition, a.Facing, a.Zoning, a.Room, a.Bathroom, a.BestBuy, a.ExclusiveStatus, " & _
                                "a.ExclusiveWho, a.ExclusiveWhen, a.ExclusiveEndDate, a.AuthorizeSaleRent, a.Remark, " & _
                                "CONVERT(nvarchar(21), ISNULL(a.Production1, 0)) + ' X ' + CONVERT(nvarchar(21), a.Production2) + ' = ' + CONVERT(nvarchar(21), a.Production3) AS 'Production', " & _
                                "CONVERT(nvarchar(21), a.Admin1) + ' X ' + CONVERT(nvarchar(21), a.Admin2) + ' = ' + CONVERT(nvarchar(21), a.Admin3) AS 'Admin', " & _
                                "CONVERT(nvarchar(21), LAWidth) + ' X ' + CONVERT(nvarchar(21), LALength) + ' = ' + CONVERT(nvarchar(21), LASF) AS 'LASQ', " & _
                                "CONVERT(nvarchar(21), BUWidth) + ' X ' + CONVERT(nvarchar(21), BULength) + ' = ' + CONVERT(nvarchar(21), BUSF) AS 'BUSQ', " & _
                                "a.[Ceiling], a.Terrain, a.District, a.FloorLoad, a.SECMK, a.Lot, a.Phase, " & _
                                "a.Furnished, a.FurnishedRemark, a.Renovated, a.RenovatedRemark, a.Developer, a.OwnerName, " & _
                                "a.OwnerMobile, a.OwnerPhone, a.OwnerFax, a.OwnerEmail, a.OwnerAddress, a.ReferLister, " & _
                                "a.LandlordName, a.LandlordMobile, a.LandlordPhone, a.LandlordFax, a.LandlordEmail, a.LandlordAddress, " & _
                                "a.ReferLandlordLister, a.RListStatus, a.SListStatus, a.RRelistStatus " & _
                                "FROM " + AppSettings("logdatasource").ToString() + ".dbo.AW_Property a LEFT OUTER JOIN " & _
                                "AW_Road r ON a.RoadId = r.RoadId LEFT OUTER JOIN AW_Project p ON a.ProjectId = p.ProjectId " & _
                                "LEFT OUTER JOIN AW_PropertyType t ON a.PropertyTypeId = t.TypeId LEFT OUTER JOIN AW_Staff rs " & _
                                "ON a.SListerId = rs.StaffId LEFT OUTER JOIN AW_Staff rr ON a.RListerId = rr.StaffId " & _
                                "LEFT OUTER JOIN AW_Location l ON r.LocationId = l.LocationId LEFT OUTER JOIN AW_State s ON l.StateId = s.StateId " & _
                                "LEFT OUTER JOIN AW_Country c on s.CountryId = c.CountryId WHERE a.StatusDelete = 0 and a.OId =@PropertyId"
        objDB.AddParameter("PropertyId", Data.SqlDbType.UniqueIdentifier, New Guid(PropertyId))
        objDB.FillData(TempDT, "AW_Property", Database.SQLCommandType.NormalString)

        objDB.CloseConnection()

        For Each ReadRow As Data.DataRow In TempDT.Rows
            lblhidPropertyId.Text = ReadRow.Item("PropertyId").ToString
            lblAddress.Text = ReadRow.Item("Address").ToString
            If ReadRow.Item("Project").ToString <> String.Empty Then
                lblProject.Text = ReadRow.Item("Project").ToString
                TRProject.Visible = True
            Else
                TRProject.Visible = False
            End If
            lblPropertyType.Text = ReadRow.Item("PropertyType").ToString
            If ReadRow.Item("KeyInOffice").ToString = "0" Then
                lblKeyInOffice.Visible = False
            End If

            If ReadRow.Item("ListType").ToString = "3" And lblhidStaffType.Text <> "2" Then   '--if Admin/Boss and listtype is 3, display both to them
                divLandlord.Visible = True
                divOwner.Visible = True
                If ReadRow.Item("RRYes").ToString = "1" Then
                    trRR.Visible = True
                    lblRRSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRAmt"))
                    lblRRPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRPSF"))
                    lblRRAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRAskAmt"))
                    lblRRAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRAskPSF"))
                    lblRRDateCreate.Text = Format(ReadRow.Item("RRCreateDate"), "dd-MMM-yyyy")
                Else
                    trRR.Visible = False
                End If
                If ReadRow.Item("RCYes").ToString = "1" Then
                    trRC.Visible = True
                    lblRCSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcAmt"))
                    lblRCPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcPSF"))
                    lblRCAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcAskAmt"))
                    lblRCAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcAskPSF"))
                    lblRCDateCreate.Text = Format(ReadRow.Item("RcCreateDate"), "dd-MMM-yyyy")
                Else
                    trRC.Visible = False
                End If
                If ReadRow.Item("RLYes").ToString = "1" Then
                    trRL.Visible = True
                    lblRLSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLAmt"))
                    lblRLPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLPSF"))
                    lblRLAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLAskAmt"))
                    lblRLAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLAskPSF"))
                    lblRLDateCreate.Text = Format(ReadRow.Item("RLCreateDate"), "dd-MMM-yyyy")
                Else
                    trRL.Visible = False
                End If
                If ReadRow.Item("RIYes").ToString = "1" Then
                    trRI.Visible = True
                    lblRISales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIAmt"))
                    lblRIPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIPSF"))
                    lblRIAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIAskAmt"))
                    lblRIAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIAskPSF"))
                    lblRIDateCreate.Text = Format(ReadRow.Item("RICreateDate"), "dd-MMM-yyyy")
                Else
                    trRI.Visible = False
                End If
                RLister.Visible = True
                If ReadRow.Item("SRYes").ToString = "1" Then
                    trSR.Visible = True
                    lblSRSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRAmt"))
                    lblSRPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRPSF"))
                    lblSRAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRAskAmt"))
                    lblSRAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRAskPSF"))
                    lblSRDateCreate.Text = Format(ReadRow.Item("SRCreateDate"), "dd-MMM-yyyy")
                Else
                    trSR.Visible = False
                End If
                If ReadRow.Item("SCYes").ToString = "1" Then
                    trSC.Visible = True
                    lblSCSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCAmt"))
                    lblSCPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCPSF"))
                    lblSCAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCAskAmt"))
                    lblSCAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCAskPSF"))
                    'Edited by minginn @ 4/4/2011 - to fix bug for cannot view property in SC
                    lblSCDateCreate.Text = Format(ReadRow.Item("SCCreateDate"), "dd-MMM-yyyy")
                Else
                    trSC.Visible = False
                End If
                If ReadRow.Item("SLYes").ToString = "1" Then
                    trSL.Visible = True
                    lblSLSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLAmt"))
                    lblSLPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLPSF"))
                    lblSLAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLAskAmt"))
                    lblSLAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLAskPSF"))
                    lblSLDateCreate.Text = Format(ReadRow.Item("SLCreateDate"), "dd-MMM-yyyy")
                Else
                    trSL.Visible = False
                End If
                If ReadRow.Item("SIYes").ToString = "1" Then
                    trSI.Visible = True
                    lblSISales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIAmt"))
                    lblSIPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIPSF"))
                    lblSIAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIAskAmt"))
                    lblSIAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIAskPSF"))
                    lblSIDateCreate.Text = Format(ReadRow.Item("SICreateDate"), "dd-MMM-yyyy")
                Else
                    trSI.Visible = False
                End If
                SLister.Visible = True
            Else
                If ListType = "2" Then      'If RENT
                    If ReadRow.Item("ReferLandlordLister").ToString = "1" Then      'if ReferLister
                        If lblhidStaffType.Text = "2" And ReadRow.Item("RListerId").ToString <> lblhidStaffId.Text Then   'if is REN
                            LRefer.Visible = True
                            LName.Visible = False
                            LPhone.Visible = False
                            LMobile.Visible = False
                            LFax.Visible = False
                            LAddress.Visible = False
                            LEmail.Visible = False
                        End If
                    End If
                    divLandlord.Visible = True
                    divOwner.Visible = False
                    If ReadRow.Item("RRYes").ToString = "1" Then
                        trRR.Visible = True
                        lblRRSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRAmt"))
                        lblRRPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRPSF"))
                        lblRRAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRAskAmt"))
                        lblRRAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RRAskPSF"))
                        lblRRDateCreate.Text = Format(ReadRow.Item("RRCreateDate"), "dd-MMM-yyyy")
                    Else
                        trRR.Visible = False
                    End If
                    If ReadRow.Item("RCYes").ToString = "1" Then
                        trRC.Visible = True
                        lblRCSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcAmt"))
                        lblRCPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcPSF"))
                        lblRCAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcAskAmt"))
                        lblRCAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RcAskPSF"))
                        lblRCDateCreate.Text = Format(ReadRow.Item("RcCreateDate"), "dd-MMM-yyyy")
                    Else
                        trRC.Visible = False
                    End If
                    If ReadRow.Item("RLYes").ToString = "1" Then
                        trRL.Visible = True
                        lblRLSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLAmt"))
                        lblRLPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLPSF"))
                        lblRLAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLAskAmt"))
                        lblRLAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RLAskPSF"))
                        lblRLDateCreate.Text = Format(ReadRow.Item("RLCreateDate"), "dd-MMM-yyyy")
                    Else
                        trRL.Visible = False
                    End If
                    If ReadRow.Item("RIYes").ToString = "1" Then
                        trRI.Visible = True
                        lblRISales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIAmt"))
                        lblRIPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIPSF"))
                        lblRIAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIAskAmt"))
                        lblRIAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("RIAskPSF"))
                        lblRIDateCreate.Text = Format(ReadRow.Item("RICreateDate"), "dd-MMM-yyyy")
                    Else
                        trRI.Visible = False
                    End If
                    trSR.Visible = False
                    trSC.Visible = False
                    trSI.Visible = False
                    trSL.Visible = False
                    SLister.Visible = False
                    RLister.Visible = True
                ElseIf ListType = "1" Then    'If SALE
                    If ReadRow.Item("ReferLister").ToString = "1" Then      'if ReferLister
                        If lblhidStaffType.Text = "2" And ReadRow.Item("SListerId").ToString <> lblhidStaffId.Text Then   'if is REN
                            ORefer.Visible = True
                            OName.Visible = False
                            OPhone.Visible = False
                            OMobile.Visible = False
                            OFax.Visible = False
                            OAddress.Visible = False
                            OEmail.Visible = False
                        End If
                    End If
                    divLandlord.Visible = False
                    divOwner.Visible = True
                    If ReadRow.Item("SRYes").ToString = "1" Then
                        trSR.Visible = True
                        lblSRSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRAmt"))
                        lblSRPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRPSF"))
                        lblSRAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRAskAmt"))
                        lblSRAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SRAskPSF"))
                        lblSRDateCreate.Text = Format(ReadRow.Item("SRCreateDate"), "dd-MMM-yyyy")
                    Else
                        trSR.Visible = False
                    End If
                    If ReadRow.Item("SCYes").ToString = "1" Then
                        trSC.Visible = True
                        lblSCSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCAmt"))
                        lblSCPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCPSF"))
                        lblSCAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCAskAmt"))
                        lblSCAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SCAskPSF"))
                        'Edited by minginn @ 4/4/2011 - to fix bug for cannot view property in SC
                        lblSCDateCreate.Text = Format(ReadRow.Item("SCCreateDate"), "dd-MMM-yyyy")
                    Else
                        trSC.Visible = False
                    End If
                    If ReadRow.Item("SLYes").ToString = "1" Then
                        trSL.Visible = True
                        lblSLSales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLAmt"))
                        lblSLPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLPSF"))
                        lblSLAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLAskAmt"))
                        lblSLAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SLAskPSF"))
                        lblSLDateCreate.Text = Format(ReadRow.Item("SLCreateDate"), "dd-MMM-yyyy")
                    Else
                        trSL.Visible = False
                    End If
                    If ReadRow.Item("SIYes").ToString = "1" Then
                        trSI.Visible = True
                        lblSISales.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIAmt"))
                        lblSIPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIPSF"))
                        lblSIAsk.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIAskAmt"))
                        lblSIAskPSF.Text = String.Format("{0:#,##0.00}", ReadRow.Item("SIAskPSF"))
                        lblSIDateCreate.Text = Format(ReadRow.Item("SICreateDate"), "dd-MMM-yyyy")
                    Else
                        trSI.Visible = False
                    End If
                    trRR.Visible = False
                    trRC.Visible = False
                    trRI.Visible = False
                    trRL.Visible = False
                    SLister.Visible = True
                    RLister.Visible = False
                End If
            End If
            'lblLister.Text = ReadRow.Item("SLister").ToString
            'lblRLister.Text = ReadRow.Item("RLister").ToString
            lblLister.Text = ReadRow.Item("SListerInitial").ToString
            lblRLister.Text = ReadRow.Item("RListerInitial").ToString
            If ReadRow.Item("KeyInOffice").ToString = "0" Then
                lblKeyInOffice.Visible = False
            End If
            lblProjectRemark.Text = ReadRow.Item("ProjectRemark").ToString
            lblDescription.Text = ReadRow.Item("PropertyDesc").ToString
            lblLASQFT.Text = String.Format("{0:#,##0.00}", ReadRow.Item("LASQ"))
            lblBUSQFT.Text = String.Format("{0:#,##0.00}", ReadRow.Item("BUSQ"))
            If ReadRow.Item("SignboardStatus").ToString = "1" Then
                trSignboard.Visible = True
                If ReadRow.Item("SignboardWhen").ToString = "" Then
                    trSignboardWhen.Visible = False
                Else
                    trSignboardWhen.Visible = True
                    lblSignboardWhen.Text = Format(ReadRow.Item("SignboardWhen"), "dd-MMM-yyyy")
                End If
                If ReadRow.Item("SignboardWhere").ToString = "" Then
                    trSignboardWhere.Visible = False
                Else
                    trSignboardWhere.Visible = True
                    lblSignboardWhere.Text = ReadRow.Item("SignboardWhere").ToString
                End If
            Else
                lblSignboard.Visible = False
                trSignboard.Visible = False
                trSignboardWhen.Visible = False
                trSignboardWhere.Visible = False
            End If
            lblSurveySheet.Text = ReadRow.Item("SurveySheet").ToString
            lblQuitRent.Text = ReadRow.Item("QuitRent").ToString
            lblAssesmentBill.Text = ReadRow.Item("AssessmentBill").ToString
            If ReadRow.Item("PendingStatus").ToString = "1" Then
                trPending.Visible = True
                If ReadRow.Item("PendingWho").ToString = "" Then
                    trPendingWho.Visible = False
                Else
                    trPendingWho.Visible = True
                    lblPendingWho.Text = ReadRow.Item("PendingWho").ToString
                End If
                If ReadRow.Item("PendingWhen").ToString = "" Then
                    trPendingWhen.Visible = False
                Else
                    trPendingWhen.Visible = True
                    lblPendingWhen.Text = Format(ReadRow.Item("PendingWhen"), "dd-MMM-yyyy")
                End If
                If ReadRow.Item("PendingWhy").ToString = "" Then
                    trPendingWhy.Visible = False
                Else
                    trPendingWhy.Visible = True
                    lblPendingWhy.Text = ReadRow.Item("PendingWhy").ToString
                End If
            Else
                lblPending.Visible = False
                trPending.Visible = False
                trPendingWho.Visible = False
                trPendingWhen.Visible = False
                trPendingWhy.Visible = False
            End If

            If ReadRow.Item("Tenure").ToString = "1" Then
                lblTenure.Text = "Freehold"
            ElseIf ReadRow.Item("Tenure").ToString = "2" Then
                lblTenure.Text = "Leasehold"
            Else
                lblTenure.Text = String.Empty
            End If
            If ReadRow.Item("Tenure").ToString = "2" Then '--Listhold
                lblListHold.Text = "(" & ReadRow.Item("ListHoldExpired").ToString & ")"
            End If

            If ReadRow.Item("Access").ToString = "1" Then
                lblAccess.Text = "Direct"
            ElseIf ReadRow.Item("Access").ToString = "2" Then
                lblAccess.Text = "Friend"
            ElseIf ReadRow.Item("Access").ToString = "3" Then
                lblAccess.Text = "Key in office"
            ElseIf ReadRow.Item("Access").ToString = "4" Then
                lblAccess.Text = "Tenant"
            ElseIf ReadRow.Item("Access").ToString = "5" Then
                lblAccess.Text = "Owner"
            ElseIf ReadRow.Item("Access").ToString = "6" Then
                lblAccess.Text = "Representative"
            ElseIf ReadRow.Item("Access").ToString = "7" Then
                lblAccess.Text = "Relative"
            ElseIf ReadRow.Item("Access").ToString = "8" Then
                lblAccess.Text = "Others"
            Else
                lblAccess.Text = String.Empty
            End If

            If ReadRow.Item("Condition").ToString = "1" Then
                lblCondition.Text = "Vacant"
            ElseIf ReadRow.Item("Condition").ToString = "2" Then
                lblCondition.Text = "Tenanted"
            ElseIf ReadRow.Item("Condition").ToString = "3" Then
                lblCondition.Text = "Owner Occupied"
            ElseIf ReadRow.Item("Condition").ToString = "4" Then
                lblCondition.Text = "Care Taker"
            ElseIf ReadRow.Item("Condition").ToString = "5" Then
                lblCondition.Text = "Under Construction"
            Else
                lblCondition.Text = String.Empty
            End If

            If ReadRow.Item("Facing").ToString = "1" Then
                lblFacing.Text = "North"
            ElseIf ReadRow.Item("Facing").ToString = "2" Then
                lblFacing.Text = "North East"
            ElseIf ReadRow.Item("Facing").ToString = "3" Then
                lblFacing.Text = "East"
            ElseIf ReadRow.Item("Facing").ToString = "4" Then
                lblFacing.Text = "South East"
            ElseIf ReadRow.Item("Facing").ToString = "5" Then
                lblFacing.Text = "South"
            ElseIf ReadRow.Item("Facing").ToString = "6" Then
                lblFacing.Text = "South West"
            ElseIf ReadRow.Item("Facing").ToString = "7" Then
                lblFacing.Text = "West"
            ElseIf ReadRow.Item("Facing").ToString = "8" Then
                lblFacing.Text = "North West"
            ElseIf ReadRow.Item("Facing").ToString = "9" Then
                lblFacing.Text = "N/A"
            Else
                lblFacing.Text = String.Empty
            End If

            If ReadRow.Item("Zoning").ToString = "1" Then
                lblZoning.Text = "Commercial"
            ElseIf ReadRow.Item("Zoning").ToString = "2" Then
                lblZoning.Text = "Residential"
            ElseIf ReadRow.Item("Zoning").ToString = "3" Then
                lblZoning.Text = "Transition"
            ElseIf ReadRow.Item("Zoning").ToString = "4" Then
                lblZoning.Text = "Industrial"
            ElseIf ReadRow.Item("Zoning").ToString = "5" Then
                lblZoning.Text = "Algriculture"
            ElseIf ReadRow.Item("Zoning").ToString = "6" Then
                lblZoning.Text = "Others"
            Else
                lblZoning.Text = String.Empty
            End If
            lblRoom.Text = ReadRow.Item("Room").ToString
            lblBathRoom.Text = ReadRow.Item("Bathroom").ToString
            If ReadRow.Item("BestBuy").ToString = "0" Then
                lblBestBuy.Visible = False
            End If
            If ReadRow.Item("ExclusiveStatus").ToString = "1" Then
                trExclusive.Visible = True
                If ReadRow.Item("ExclusiveEndDate").ToString = "" Then
                    trExclusiveEndDate.Visible = False
                Else
                    trExclusiveEndDate.Visible = True
                    lblExclusiveEndDate.Text = Format(ReadRow.Item("ExclusiveEndDate"), "dd-MMM-yyyy")
                End If
                If ReadRow.Item("ExclusiveWhen").ToString = "" Then
                    trExclusiveWhen.Visible = False
                Else
                    trExclusiveWhen.Visible = True
                    lblExclusiveWhen.Text = Format(ReadRow.Item("ExclusiveWhen"), "dd-MMM-yyyy")
                End If
                If ReadRow.Item("ExclusiveWho").ToString = "" Then
                    trExclusiveWho.Visible = False
                Else
                    trExclusiveWho.Visible = True
                    lblExclusiveWho.Text = ReadRow.Item("ExclusiveWho").ToString
                End If
            Else
                lblExclusiveStatus.Visible = False
                trExclusive.Visible = False
                trExclusiveEndDate.Visible = False
                trExclusiveWhen.Visible = False
                trExclusiveWho.Visible = False
            End If
            If ReadRow.Item("AuthorizeSaleRent").ToString = "0" Then
                lblAuthorize.Visible = False
            End If
            lblRemark.Text = ReadRow.Item("Remark").ToString
            lblProduction.Text = ReadRow.Item("Production").ToString
            lblAdmin.Text = ReadRow.Item("Admin").ToString
            lblProduction.Text = ReadRow.Item("Production").ToString
            lblFloorLoad.Text = ReadRow.Item("FloorLoad").ToString
            lblSECMK.Text = ReadRow.Item("SECMK").ToString
            lblCeiling.Text = ReadRow.Item("Ceiling").ToString
            lblTerrain.Text = ReadRow.Item("Terrain").ToString
            lblDistrict.Text = ReadRow.Item("District").ToString
            lblLot.Text = ReadRow.Item("Lot").ToString
            lblPhase.Text = ReadRow.Item("Phase").ToString

            If ReadRow.Item("Furnished").ToString = "1" Then
                lblFurnised.Text = "Furnished"
            ElseIf ReadRow.Item("Furnished").ToString = "2" Then
                lblFurnised.Text = "Not Furnished"
            ElseIf ReadRow.Item("Furnished").ToString = "3" Then
                lblFurnised.Text = "Partially Furnished"
            Else
                lblFurnised.Text = String.Empty
            End If
            lblFurnishedRemark.Text = ReadRow.Item("FurnishedRemark").ToString

            If ReadRow.Item("Renovated").ToString = "1" Then
                lblRenovated.Text = "Renovated"
            ElseIf ReadRow.Item("Renovated").ToString = "2" Then
                lblRenovated.Text = "Not Renovated"
            ElseIf ReadRow.Item("Renovated").ToString = "3" Then
                lblRenovated.Text = "Partially Renovated"
            Else
                lblRenovated.Text = String.Empty
            End If
            lblRenovatedRemark.Text = ReadRow.Item("RenovatedRemark").ToString
            lblDeveloper.Text = ReadRow.Item("Developer").ToString
            lblName.Text = ReadRow.Item("OwnerName").ToString
            lblMobile.Text = ReadRow.Item("OwnerMobile").ToString
            lblPhone.Text = ReadRow.Item("OwnerPhone").ToString
            lblEmail.Text = ReadRow.Item("OwnerEmail").ToString
            lblFax.Text = ReadRow.Item("OwnerFax").ToString
            lblOwnerAddress.Text = ReadRow.Item("OwnerAddress").ToString
            If ReadRow.Item("ReferLister").ToString = "0" Then
                lblReferToLister.Visible = False
            End If
            lblLandlordName.Text = ReadRow.Item("LandlordName").ToString
            lblLandlordMobile.Text = ReadRow.Item("LandlordMobile").ToString
            lblLandlordPhone.Text = ReadRow.Item("LandlordPhone").ToString
            lblLandlordEmail.Text = ReadRow.Item("LandlordEmail").ToString
            lblLandlordFax.Text = ReadRow.Item("LandlordFax").ToString
            lblLandlordAddress.Text = ReadRow.Item("LandlordAddress").ToString
            If ReadRow.Item("ReferLandlordLister").ToString = "0" Then
                lblLandlordReferToLister.Visible = False
            End If
        Next
    End Sub

    Private Sub LoadPropertyPhoto(ByVal PropertyID As String)

        Dim objDB As New Database(AppSettings("datasource"), AppSettings("database"), AppSettings("username"), AppSettings("password"), AppSettings("timeout"), AppSettings("pooling"))
        Dim TempDT As New Data.DataTable

        objDB.OpenConnection()
        objDB.dbVariable.SQLString = "SELECT Picture,PictureDesc,isThumbnail FROM AW_Picture WHERE PropertyId=@PropertyId"
        objDB.AddParameter("PropertyId", Data.SqlDbType.UniqueIdentifier, New Guid(PropertyID))
        objDB.FillData(TempDT, "Photo", Database.SQLCommandType.NormalString)
        objDB.CloseConnection()

        Dim TempDV As New Data.DataView(TempDT)

        TempDV.RowFilter = "isThumbnail=1"

        If TempDV.Count > 0 Then
            imgThumbnail.ImageUrl = "property/" & TempDV(0).Item("Picture").ToString
            aThumbnail.HRef = "property/" & TempDV(0).Item("Picture").ToString
            aThumbnail.Title = TempDV(0).Item("PictureDesc").ToString
        End If

        TempDV.RowFilter = "isThumbnail<>1"
        dlUploadedPhoto.DataSource = TempDV
        dlUploadedPhoto.DataBind()

    End Sub

    Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBack.Click
        Dim strBack As String = Session("Back").ToString
        Dim arr() As String = strBack.Split("ڡ")
        Response.Redirect(arr(0).ToString)
    End Sub

End Class
